/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package negocio.CRUD;

import Vo.VoAccion;
import accesoDatos.negocio.DAOS.AccionDao;
import accesoDatos.negocio.entity.Accion;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author Beltran
 */
public class CRUDAcciones {
        AccionDao nuevo = new AccionDao();
        Accion entity = new Accion();
        public static EntityManagerFactory emf;
        public static EntityManager em;
    public CRUDAcciones(VoAccion vo){
        emf = Persistence.createEntityManagerFactory("parcialmlgPU", System.getProperties());
        em = emf.createEntityManager();
        entity.setId(vo.getId());
        entity.setName(vo.getName());
        entity.setSymbol(vo.getSymbol());
        entity.setDescription(vo.getDescription());}
    
        public String crearAccion(){
        return nuevo.create(entity,em);
        }
        public void borrarAccion(){
        nuevo.delete(entity, em);
        }
        public VoAccion buscarAccion(String name){
        entity = nuevo.buscarNombre(name, em);
        return entity.toVO();
        }
        public void actualizarAccion(String name){
        nuevo.update(name, entity, em);
        }
        
}
